const { Sequelize } = require('sequelize');

// 使用 URI 连接数据库

const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, {
  host: process.env.DB_HOST,
  dialect: 'mysql', // 或 'mysql', 'sqlite', 'mssql'
  logging:false
});
// 测试数据库链接是否成功
// (async function(){
//   try {
//     await sequelize.authenticate();
//     console.log('Connection has been established successfully.');
//   } catch (error) {
//     console.error('Unable to connect to the database:', error);
//   }
// })()

module.exports = sequelize;
